home *** CD-ROM | disk | FTP | other *** search
/ MacHack 2000 / MacHack 2000.toast / pc / The Hacks / Genie / Projects / A-line / Scripts / AMake < prev    next >
Encoding:
Text File  |  2000-06-24  |  4.8 KB  |  229 lines

  1. # AMake
  2. #
  3. # Synopsis:
  4. #    AMake [ <maketarget> ]
  5. #        [ --arch 68K | PPC | Fat ]
  6. #        [ --build Debug | Release | all ]
  7. #
  8. # Options:
  9. #    --arch        # Specify which architecture to build for.  No PPC support yet.
  10. #    --build        # Specify which build type.
  11.  
  12. # Start the timer
  13. Set TIME0 `date -n`
  14.  
  15. # Set some variables
  16. Execute "ALDirMacros"
  17. set PROFILE ":{MANIFEST}:Profile.mpwsh"
  18.  
  19. # Defaults
  20. Set PREMAKEFILE "{SCRIPTS}Premake.mk"
  21. Set DEPMAKEFILE "{SCRIPTS}DepMake.mk"
  22. Set MAKEFILE "{SCRIPTS}Master.mk"
  23. Set MAKETARGET default
  24.  
  25. # Parse the command line.
  26. Loop
  27.     Break If {#} == 0
  28.     If "{1}" == "--arch"
  29.         Set ARCH "{2}"
  30.         Shift; Shift
  31.     Else If "{1}" == "--build"
  32.         If "{2}" == "Debug" || "{2}" == "Release" || "{2}" == "all" || "{2}" == "--default"
  33.             Set BUILD "{2}"
  34.         End
  35.         Shift; Shift
  36.     Else If "{1}" == "--target"
  37.         Set MAKETARGET "{2}"
  38.         Shift; Shift
  39.     Else
  40.         #Echo "{0}: Error: Unknown thing '{1}' on the command line."
  41.         #Exit 1
  42.         Set MAKETARGET "{1}"
  43.         Shift
  44.     End
  45. End
  46.  
  47. If !"{ARCH}" || "{ARCH}" == "--default"
  48.     Set ARCH 68K  # Change this to use current arch
  49.     If `Gestalt 'cput'` >= 256
  50.         Set ARCH PPC
  51.     End If
  52. End
  53. Set COMPILER MW
  54. If !"{BUILD}" || "{BUILD}" == "--default"
  55.     Set BUILD Debug
  56. End
  57.  
  58. Set ACTION "make"
  59.  
  60. # Check to make sure that either a project was specified or that we're already in one.
  61. If !`Exists ":Manifest:"`
  62.     Echo "{0}: There must be a project selected."
  63.     Exit 1
  64. End
  65.  
  66. Begin
  67.     
  68.     If `Exists -f "{PROFILE}"`
  69.         Execute "{PROFILE}"
  70.     End
  71.     
  72.     Set -e PROJNAME "{NAME}"
  73.     
  74.     # Mainly something to click on and hit Enter to rebuild
  75.     Echo "Making {NAME}"
  76.     Begin
  77.         Set SAVEEXIT {Exit}
  78.         Set Exit 0
  79.         Echo `echo "Making {NAME}" | sed "s/./-/g"`
  80.         Set Exit {SAVEEXIT}
  81.     End ≥ Dev:Null
  82.     Echo ""
  83.     Echo -n "({0}"
  84.     If "{ARCH}"
  85.         Echo -n " --arch {ARCH}"
  86.     End
  87.     If "{BUILD}"
  88.         Echo -n " --build {BUILD}"
  89.     End
  90.     Echo ")"
  91.     Echo ""
  92.     
  93.     set TIME1 `date -n`
  94.     set TIME2 {TIME1}
  95.     
  96.     set MAKE "dmake -n"
  97.     set CMDS "Dev:stdout"
  98.     set LABEL "# Select the following commands and hit Enter to make {NAME}."
  99.     set PART2 "Building dependent targets"
  100.     set PART4 "Running 'dmake -n'"
  101.     set PART5 "Actually building {NAME}"
  102.     
  103.     set TIME3 `date -n`
  104.     
  105.     Set LABDIR `FindLabFolder`
  106.     Set PROJLABDIR "{LABDIR}{NAME}:"
  107.     If !`Exists "{PROJLABDIR}"`
  108.         NewFolder "{PROJLABDIR}"
  109.     End
  110.     
  111.     Set -e RULESDIR "{PROJLABDIR}{RULES}:"
  112.     If !`Exists "{RULESDIR}"`
  113.         NewFolder "{RULESDIR}"
  114.     End
  115.     
  116.     Echo "Pre-making..."
  117.     
  118.     Premake.pl
  119.     #RunMake PROJLABDIR="{PROJLABDIR}" -f "{PREMAKEFILE}" premake
  120.     SetFile -c 'R*ch' "{RULESDIR}Sources.mk" "{RULESDIR}Imports.mk"
  121.     
  122.     set TIME4 `date -n`
  123.     
  124.     Echo "Making dependencies..."
  125.     If 0 # `Exists -d "[Dependencies]"`
  126.         If !`Exists -f "{RULESDIR}Dependencies.mk"`
  127.             Set HEADER "# Make dependencies generated automatically by AMake."
  128.             Echo "{HEADER}" > "{RULESDIR}Dependencies.mk"
  129.             Echo "" >> "{RULESDIR}Dependencies.mk"
  130.             Catenate `Files -f ":{DEPS}:"` >> "{RULESDIR}Dependencies.mk"
  131.             SetFile -c 'R*ch' "{RULESDIR}Dependencies.mk"
  132.         End If
  133.         RunMake -f "{DEPMAKEFILE}" depmake
  134.     Else
  135.         MakeDeps
  136.     End If
  137.     
  138.     Catenate ":Manifest:Demographics.mk" "{RULESDIR}Sources.mk" "{RULESDIR}Imports.mk" "{RULESDIR}Dependencies.mk" > "Include.mk"
  139.     SetFile -c 'R*ch' "Include.mk"
  140.     
  141.     Echo "Making..."
  142.     RunMake BUILD="{BUILD}" ARCH="{ARCH}" PROJLABDIR="{PROJLABDIR}" -f "{MAKEFILE}" "{MAKETARGET}"
  143.     
  144.     Delete -y "Include.mk"
  145.     
  146.     Echo "Okay, enough of that."
  147.     
  148.     set TIME5 `date -n`
  149.     
  150.     #playsound "Indigo"
  151.     
  152.     echo ""
  153.     
  154.     set DELTA `evaluate {TIME5} - {TIME0}`
  155.     if {DELTA} == 1
  156.         set TIME "1 second"
  157.     else if {DELTA} <= 60
  158.         set TIME "{DELTA} seconds"
  159.     else
  160.         set MIN `evaluate {DELTA} div 60`
  161.         set SEC `evaluate {DELTA} % 60`
  162.         if `evaluate {SEC} div 10` == 0
  163.             set PADSEC 0
  164.         end
  165.         set MIN `evaluate {DELTA} div 60`
  166.         set TIME "{MIN}:{PADSEC}{SEC}"
  167.     end
  168.     echo "# Total build time:  {TIME}"
  169.     
  170.     set DELTA1 `evaluate {TIME1} - {TIME0}`
  171.     if {DELTA1} == 1
  172.         set SECONDS1 second
  173.     else
  174.         set SECONDS1 seconds
  175.     end
  176.     echo "# Initial overhead took {DELTA1} {SECONDS1}."
  177.     
  178.     if "{ACTION}" == "make" and "{PREBUILD}" != ""
  179.         set DELTA2 `evaluate {TIME2} - {TIME1}`
  180.         if {DELTA2} == 1
  181.             set SECONDS2 second
  182.         else
  183.             set SECONDS2 seconds
  184.         end
  185.         #echo "# {PART2} took {DELTA2} {SECONDS2}."
  186.     end
  187.     
  188.     set DELTA3 `evaluate {TIME3} - {TIME2}`
  189.     if {DELTA3} == 1
  190.         set SECONDS3 second
  191.     else
  192.         set SECONDS3 seconds
  193.     end
  194. #    echo "# Constructing the arguments to dmake took {DELTA3} {SECONDS3}."
  195.     
  196.     set DELTA `evaluate {TIME4} - {TIME3}`
  197.     if {DELTA} == 1
  198.         set TIME "1 second"
  199.     else
  200.         set TIME "{DELTA} seconds"
  201.     end
  202.     echo "# {PART4} took {TIME}."
  203.     
  204.     if "{ACTION}" == "make"
  205.         set DELTA `evaluate {TIME5} - {TIME4}`
  206.         if {DELTA} == 1
  207.             set TIME "1 second"
  208.         else if {DELTA} <= 60
  209.             set TIME "{DELTA} seconds"
  210.         else
  211.             set MIN `evaluate {DELTA} div 60`
  212.             set SEC `evaluate {DELTA} % 60`
  213.             set PADSEC ""
  214.             if `evaluate {SEC} div 10` == 0
  215.                 set PADSEC 0
  216.             end
  217.             set MIN `evaluate {DELTA} div 60`
  218.             set TIME "{MIN}:{PADSEC}{SEC}"
  219.         End
  220.         Echo "# {PART5} took {TIME}."
  221.     End
  222.     Echo ""
  223.  
  224. End
  225.  
  226.  
  227. Exit
  228. # The end.
  229.